package com.hea7en.article.controller;

import com.hea7en.article.service.ArticleService;
import com.hea7en.common.constants.ArticleConstants;
import com.hea7en.model.article.dto.ArticleHomeDto;
import com.hea7en.model.article.pojo.ApArticle;
import com.hea7en.model.common.dto.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: hea7en
 * @Date: 2024/8/18 9:21 PM
 * @Description: 文章模块控制层
 */
@RestController
@RequestMapping("/api/v1/article")
@Api(tags = "文章相关接口")
public class ArticleController {

    @Autowired
    ArticleService articleService;

    /**
     * 文章首页数据加载
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation("文章首页数据加载")
    public ResponseResult<ApArticle> load(@RequestBody ArticleHomeDto articleHomeDto) {

        return articleService.loadArticle(ArticleConstants.LOADTYPE_LOAD_MORE, articleHomeDto);
    }

    /**
     * 文章更多数据加载
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/loadmore")
    @ApiOperation("文章更多数据加载")
    public ResponseResult<ApArticle> loadMore(@RequestBody ArticleHomeDto articleHomeDto) {

        return articleService.loadArticle(ArticleConstants.LOADTYPE_LOAD_MORE, articleHomeDto);
    }

    /**
     * 文章最新数据加载
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/loadnew")
    @ApiOperation("文章最新数据加载")
    public ResponseResult<ApArticle> loadNew(@RequestBody ArticleHomeDto articleHomeDto) {

        return articleService.loadArticle(ArticleConstants.LOADTYPE_LOAD_NEW, articleHomeDto);
    }
}
